package com.attendance.controller;

import com.attendance.common.CommonPage;
import com.attendance.common.CommonResult;
import com.attendance.pojo.Pages;
import com.attendance.pojo.PersonalScore;
import com.attendance.service.PersonalScoreService;
import com.attendance.vo.PersonalScoreVo;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/personalScore")
public class PersonalScoreController {

    @Autowired
    private PersonalScoreService personalScoreService;

    /**
     * 分页处理的个人综合评分列表信息
     * @return
     */
    @GetMapping()
    public CommonResult selectAll(Pages pages){
        return personalScoreService.selectAll(pages);
    }

    /**
     * 分页处理的根据输入框查询的个人综合评分列表信息
     * @return
     */
    @GetMapping("/selectByName")
    public CommonResult selectByName(Pages pages,PersonalScoreVo personalScoreVo){
        return personalScoreService.selectByName(personalScoreVo,pages);
    }

    /**
     * 根据个人综合评分id查询的详情页信息
     * @param psId
     * @return
     */
    @GetMapping("{psId}")
    public CommonResult selectById(@PathVariable("psId") int psId){
        return personalScoreService.selectById(psId);
    }

    /**
     * 新增个人综合评分信息
     * @param personalScore
     * @return
     */
    @PostMapping("/addPersonalScore")
    public CommonResult addPersonalScore(@RequestBody PersonalScore personalScore){
        return personalScoreService.addPersonalScore(personalScore);
    }

    /**
     * 修改个人综合评分信息
     * @param personalScore
     * @return
     */
    @PutMapping
    public CommonResult updatePersonalScore(@RequestBody PersonalScore personalScore){
        return personalScoreService.updatePersonalScore(personalScore);
    }

    /**
     * 逻辑删除个人综合评分
     * @param psId
     * @return
     */
    @PutMapping("{psId}")
    public CommonResult modifyPersonalScore(@PathVariable String psId){
        return personalScoreService.modifyPersonalScore(psId);
    }
}
